import cTitle from "components/title";
export default {
  data() {
    return {
      //  海报入口显示
      // poster_center_show: 0,
      // 爱心值海报自定义名称
      // love_poster_name: 0,

      imgPath: window.location.origin + "/static/local/",
      show_usable: false, //是否显示可用爱心值
      // 登陆会员冻结爱心值
      froze: 0,
      froze_name: "", //冻结兑换值
      //爱心值自定义名称
      love_name: "",
      // 登陆会员可用爱心值
      usable: 0,
      //是否可提现
      withdraw_status: false,
      //是否可以充值
      recharge_status: false,
      //兑换值激活
      usable_name: "",
      //转换消费积分
      change_integral:{},
      // 转换积分是否开启
      transformation_point:false,
      activation_record: false, // 激活记录是否开启
      // 转换冻结爱心值
      usable_love_to_freeze:false,
      withdrawDate: {
        day: 1,
        disable: false,
        day_msg: ""
      },
      love_queue: "",
      no_recharge: 0
    };
  },
  computed: {},
  methods: {
    getyz_basic_info() {
      let yz_basic_info = localStorage.getItem("yz_basic_info");
      if (yz_basic_info) {
        yz_basic_info = JSON.parse(yz_basic_info);
      }
    },
    getBalance() {
      let that = this;
      $http.get("plugin.new-love.Frontend.Controllers.page.index", {}, "加载中").then(
        response => {
          if (response.result === 1) {
            if (response.data.withdraw_date) {
              this.withdrawDate = response.data.withdraw_date;
            }
            this.froze = response.data.froze;
            this.love_name = response.data.love_name;
            window.localStorage.love_name = this.love_name;
            //设置微信title
            this.fun.setWXTitle(this.love_name);
            this.usable = response.data.usable;
            this.no_recharge = response.data.no_recharge;
            this.withdraw_status = response.data.withdraw_status;
            this.recharge_status = response.data.recharge_status;
            this.froze_name = response.data.froze_name;
            this.usable_name = response.data.usable_name;
            this.change_integral = response.data.change_integral;
            this.transformation_point = response.data.transformation_point;
            this.usable_love_to_freeze = response.data.usable_love_to_freeze;
            // this.poster_center_show = response.data.poster_center_show;
            // this.love_poster_name = response.data.love_poster_name;
            this.activation_record = response.data.activation_record;
            this.love_queue = response.data.love_queue !== undefined ? JSON.parse(JSON.stringify(response.data["love_queue"])) : "";
            this.show_usable = response.data.show_usable;
          } else {
            that.$dialog.alert({ message: response.msg });
          }
        },
        response => {
          console.log(response);
        }
      );
    },
    gotoPage(url) {
      if (url == "new_loveWithdrawals") {
        if (this.withdrawDate.disable == 1) {
          this.$toast(this.withdrawDate.day_msg);
          return;
        }
      }
      if (url == "LoveRecharge" && JSON.parse(window.localStorage.getItem("globalParameter")).ios_virtual_pay == "1" && this.fun.isIphone()) {
        this.$dialog.alert({
          message: "十分抱歉，由于相关规定，你暂时无法在这里充值！"
        });
        return false;
      }
      if (url== "love-integral") {
        let time = new Date().getTime();
        let {start,end} = this.change_integral;
        let starttime = new Date(start.replace(/-/g,'/')).getTime();
        let endtime = new Date(end.replace(/-/g,'/')).getTime();
        if(starttime>time || time>endtime){
          this.$toast({
            type: 'html',
            message: `<p>当前不能转换</p><p>请在${start}到${end}转换</p>`,
          });
          return false;
        }
      }

      this.$router.push(this.fun.getUrl(url));
    }
  },
  activated() {
    this.getyz_basic_info();
    this.getBalance();
  },
  components: { cTitle }
};
